/**
 * 功能开关修改
 */
angular.module('inspinia').controller("updateFunctionManage", function($scope, $http, $stateParams,$state) {
    //防止和查询页面共用缓存
    $scope.functionTypeListChoose = angular.copy($scope.functionTypeList);
    $scope.functionTypeListChoose.unshift({text:"请选择", value:null});

    //查询
    $scope.query = function(){
        $http({
            url:"functionManager/getFunctionManagerInfo?functionNumber=" + $stateParams.functionNumber,
            method:"get"
        }).success(function(result){
            if (!result || !result.status){
                $scope.notice (result.msg);
                return;
            }
            $scope.baseInfo = result.info;
        }).error(function(){
            $scope.submitting = false;
            $scope.notice("服务器异常");
        });
    };
    $scope.query();

    //提交
    $scope.submit = function(){
        $scope.submitting = true;
        $http({
            url:"functionManager/updateFunctionManage",
            method:"post",
            data:$scope.baseInfo
        }).success(function(result){
            $scope.submitting = false;
            $scope.notice (result.msg);
            if(result.status){
                $state.transitionTo ('func.switch',null,{reload:true } );
            }
        }).error(function(){
            $scope.submitting = false;
            $scope.notice("服务器异常");
        });
    };

});